using UnityEngine.UI;

public class DialogLockedArena : GenericDialog
{
	public int arenaNumber;

	public Text textPointsNeeded;

	public Button buttonUnlockArenas;

	public Text textPriceUnlockArenas;

	public Text textBonusLivesUnlockArenas;

	private void OnEnable()
	{
		if (Globals.appState != 0 && Globals.appState != AppState.unknown)
		{
			UpdateControls();
			//Economy.PurchaseFinishedEvent += OnPurchaseFinished;
			//CustomAnalytics.LogUIEvent("Menu", "Locked Arena");
			//GenericDialog.FireDialogEnabledEvent();
		}
	}

	private void OnDisable()
	{
		//if (Globals.appState != 0 && Globals.appState != AppState.unknown)
		//{
		//	Economy.PurchaseFinishedEvent -= OnPurchaseFinished;
		//}
	}

	private void OnPurchaseFinished(bool succes)
	{
		if (succes)
		{
			UserInterface.GetInstance().CloseModalDialog();
			UpdateControls();
		}
	}

	private void UpdateControls()
	{
		textPointsNeeded.text = EconomySettings.GetUnlockPointsForArena(arenaNumber).ToString();
		//buttonUnlockArenas.interactable = Economy.CanPurchase(IAPManager.ProductType.Unlock);
		//textPriceUnlockArenas.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.Unlock);
		//textBonusLivesUnlockArenas.text = EconomySettings.livesBonusForUnlockPurchase.ToString();
	}

	public void OnButtonUnlock()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Locked Arena - Unlock");
        UserInterface.GetInstance().dialogPurchaseTips.Reset();
		AdManager.single.ShowVideo(() =>
		{
			Economy.instance.IAPSuccess(IAPManager.ProductType.Unlock);
            UserInterface.GetInstance().dialogPurchaseTips.PurchaseSuccess();
        });
        UserInterface.GetInstance().OnDisplayPurchaseTips();
    }
}
